import request from '@/utils/request'

const api_name = '/edu/course'

export default {
  saveCourseInfo(courseInfo) {
    return request({
      url: `${api_name}/addCourse`,
      method: 'post',
      data: courseInfo
    })
  },
  getPageList(page, limit, searchObj) {
    return request({
      url: `${api_name}/coursePageLikeQuery/${page}/${limit}`,
      method: 'get',
      params: searchObj
    })
  },
  // 数据回显
  // @GetMapping("/showCourseForm/{id}")
  getCourseInfoById(id) {
    return request({
      url: `${api_name}/showCourseForm/${id}`,
      method: 'get'
    })
  },
  // @PutMapping("/updateCourseForm/{id}")
  updateCourseInfoById(courseInfo) {
    return request({
      url: `${api_name}/updateCourseForm/${courseInfo.id}`,
      method: 'put',
      data: courseInfo
    })
  },

  // 发布api
  // 获取course信息
  getCoursePublishInfoById(id) {
    return request({
      url: `${api_name}/showCoursePublish/${id}`,
      method: 'get'
    })
  },

  // 发布course
  publishCourse(id) {
    return request({
      url: `${api_name}/publishCourse/${id}`,
      method: 'put'
    })
  },

  // 删除课程
  removeById(id) {
    return request({
      url: `${api_name}/deleteCourse/${id}`,
      method: 'delete'
    })
  }

}